const path = require('path')
const webpack = require('webpack')
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin')
const { merge } = require('webpack-merge')
const baseConfig = require('./webpack.base.js')

module.exports = merge(baseConfig, {
  mode: 'development',
  target: 'web',
  devtool: 'cheap-module-source-map',
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoEmitOnErrorsPlugin(),
    new ReactRefreshWebpackPlugin()
  ],
  devServer: {
    port: 3000,
    compress: false,
    hot: true,
    open: true,
    historyApiFallback: true, // 解决history路由404问题
    static: {
      directory: path.join(__dirname, '../public')
    }
  }
})
